package co.gov.medellin.ssti.sub.model.service.impl;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import co.gov.medellin.ssti.sub.model.dao.SubprogramaDAO;
import co.gov.medellin.ssti.sub.model.dao.exception.DAOException;
import co.gov.medellin.ssti.sub.model.service.SubprogramaService;
import co.gov.medellin.ssti.sub.model.vo.AtributoVO;
import co.gov.medellin.ssti.sub.model.vo.SubprogramaVO;
import co.gov.medellin.ssti.sub.web.form.SubprogramaForm;

@Service
public class SubprogramaServiceImpl implements SubprogramaService {
	@Autowired
	SubprogramaDAO subprogramaDAOImpl2;

	public List<SubprogramaVO> loadAllSubprogramas() throws DAOException {
		try {
			return subprogramaDAOImpl2.loadAllSubprogramas();
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public List<SubprogramaVO> loadAllSubprogramasByPrograma(String programaCode)
			throws DAOException {
		try {
			return subprogramaDAOImpl2
					.loadAllSubprogramasByPrograma(programaCode);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public AtributoVO getGestor(String codeSubprograma) throws DAOException {
		try {
			return subprogramaDAOImpl2.getGestor(codeSubprograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findSubprogramaByCriteria(
			SubprogramaVO criteria) throws DAOException {
		try {
			return subprogramaDAOImpl2.findSubprogramaByCriteria(criteria);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findInformacionSubprogramaByCriteria(
			SubprogramaVO criteria) throws DAOException {
		try {
			return subprogramaDAOImpl2
					.findInformacionSubprogramaByCriteria(criteria);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findSubprogramaByCriteria(
			SubprogramaVO criteria, Long codeUser, String groupUserName,
			Long areaUser) throws DAOException {
		try {
			return subprogramaDAOImpl2.findSubprogramaByCriteria(criteria,
					codeUser, groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findAllowedSubprogramaWithGestorByCriteria(
			SubprogramaVO criteria, Long codeUser, String groupUserName,
			Long areaUser) throws DAOException {
		try {
			return subprogramaDAOImpl2
					.findAllowedSubprogramaWithGestorByCriteria(criteria,
							codeUser, groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findSubprograma(SubprogramaVO criteria,
			Long codeUser, String groupUserName, Long areaUser)
			throws DAOException {
		try {
			return subprogramaDAOImpl2.findSubprograma(criteria, codeUser,
					groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findSubprogramaUser(Long codeUser,
			String userGroupName, Long codeprograma, Long codeArea) {
		try {
			SubprogramaVO criteria = new SubprogramaVO();
			criteria.setCodeUsuario(codeUser);
			criteria.setCodePrograma(codeprograma);

			return subprogramaDAOImpl2.findSubprograma(criteria, codeUser,
					userGroupName, codeArea);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findAllowedSubprograma(
			SubprogramaVO criteria, Long codeUser, String groupUserName,
			Long areaUser) throws DAOException {
		try {
			return subprogramaDAOImpl2.findAllowedSubprograma(criteria,
					codeUser, groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public int insertBeneficioOtorgado(String[] strArr, int i,
			String fechaBeneficio) throws DAOException {
		try {
			return subprogramaDAOImpl2.insertBeneficioOtorgado(strArr, i,
					fechaBeneficio);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public int updateBeneficioOtorgado(String[] strArr, int i,
			String DateBenefit, String codeBot) throws DAOException {
		try {
			return subprogramaDAOImpl2.updateBeneficioOtorgado(strArr, i,
					DateBenefit, codeBot);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public int updateBeneficioOtorgado(String[] strArr, int i,
			String DateBenefit, String codeBot, String tipoBot,
			Long codigoHechoVictimizante) throws DAOException {
		try {
			return subprogramaDAOImpl2.updateBeneficioOtorgado(strArr, i,
					DateBenefit, codeBot, tipoBot, codigoHechoVictimizante);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public SubprogramaVO findPropiedadesSubprograma(long codeSubpro) {
		try {
			return subprogramaDAOImpl2.findPropiedadesSubprograma(codeSubpro);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findCodMaxBenOtor() {
		try {
			return subprogramaDAOImpl2.findCodMaxBenOtor();
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findCantidadDisponible() {
		try {
			return subprogramaDAOImpl2.findCantidadDisponible();
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findMaxCodigo() {
		try {
			return subprogramaDAOImpl2.findMaxCodigo();
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public int insertBeneficio(SubprogramaForm subform, String user,
			String strTerminal, String strDate) {
		try {
			return subprogramaDAOImpl2.insertBeneficio(subform, user,
					strTerminal, strDate);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public boolean findEstadoSubprogramaByCodigo(long codigo) {
		try {
			return subprogramaDAOImpl2.findEstadoSubprogramaByCodigo(codigo);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findActivarSubprogramas(long codePrograma) {
		try {
			return subprogramaDAOImpl2.findActivarSubprogramas(codePrograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findActivarSubprogramas(Long codeUser,
			String groupUserName, Long areaUser) {
		try {
			return subprogramaDAOImpl2.findActivarSubprogramas(codeUser,
					groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public Collection<SubprogramaVO> findSubprogramasVigentes(
			SubprogramaVO criteria, Long codeUser, String groupUserName,
			Long areaUser) {
		try {
			return subprogramaDAOImpl2.findSubprogramasVigentes(criteria,
					codeUser, groupUserName, areaUser);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findNombreByCodigo(long codeSub) {
		try {
			return subprogramaDAOImpl2.findNombreByCodigo(codeSub);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findCodigoSubprogramaByCodigoBOT(long codeBOT) {
		try {
			return subprogramaDAOImpl2
					.findCodigoSubprogramaByCodigoBOT(codeBOT);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public boolean isRelacionadoConSede(long codeSub) {
		try {
			return subprogramaDAOImpl2.isRelacionadoConSede(codeSub);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public String findCodigoProgramaByCodigoSubprograma(long codeSubprograma) {
		try {
			return subprogramaDAOImpl2
					.findCodigoProgramaByCodigoSubprograma(codeSubprograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public boolean isSubprogramaParaGrupoFamiliar(Long codeSubprograma) {
		try {
			return subprogramaDAOImpl2
					.isSubprogramaParaGrupoFamiliar(codeSubprograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	public SubprogramaVO findSubprogramaByCodigo(Long codeSubprograma) {
		try {
			return subprogramaDAOImpl2.findSubprogramaByCodigo(codeSubprograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	@Override
	public int insertBeneficioOtorgadoEmpresa(String[] strArr, int i,
			String fechaBeneficio) throws DAOException {
		try {
			return subprogramaDAOImpl2.insertBeneficioOtorgadoEmpresa(strArr,
					i, fechaBeneficio);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	@Override
	public int inactivarSubprograma(SubprogramaVO subprogramaVO) {
		try {
			return subprogramaDAOImpl2.inactivarSubprograma(subprogramaVO);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	@Override
	public Collection<SubprogramaVO> findCodeSubprogramasByCodePrograma(
			Long codePrograma) {
		try {
			return subprogramaDAOImpl2
					.findCodeSubprogramasByCodePrograma(codePrograma);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

	@Override
	public int update(SubprogramaVO subprogramaVO) {
		try {
			return subprogramaDAOImpl2.update(subprogramaVO);
		} catch (Exception e) {
			throw new DAOException(e);
		}
	}

}
